package com.renyr.decorator;

/**
 * 装饰模式
 *
 * 给一类对象增加新的功能，装饰方法与具体的内部逻辑无关。例如：
 */
public class Decorator implements Source {
    private Source source;

    public void setSource(Source source) {
        this.source = source;
    }

    @Override
    public void method() {
        source.method();
    }


    public static void main(String[] args) {
        SourceImpl1 sourceImpl1 = new SourceImpl1();
        SourceImpl2 sourceImpl2 = new SourceImpl2();
        Decorator decorator = new Decorator();

        decorator.setSource(sourceImpl1);

//        decorator.setSource(sourceImpl2);
        decorator.method();
    }
}
